package com.xykj.enterprise.wechat.busi.service.contact;

import com.xykj.enterprise.wechat.bean.ext.identity.UserInfo3rd;
import com.xykj.enterprise.wechat.busi.config.ExtClient;
import com.xykj.enterprise.wechat.core.dao.SuiteTicketDao;
import com.xykj.enterprise.wechat.core.dao.SysParamDao;
import com.xykj.enterprise.wechat.core.dao.UserDao;
import com.xykj.enterprise.wechat.core.model.dodb.User;
import com.xykj.enterprise.wechat.util.Const;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.Map;

@Repository
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userDao;
    @Autowired
    private ExtClient extClient;
    @Autowired
    private SysParamDao sysParamDao;
    @Autowired
    private SuiteTicketDao suiteTicketDao;


    @Override
    public User getById(String userId) {
        return userDao.getById(userId);
    }

    @Override
    public UserInfo3rd get(String suiteId, String code,String secret) {
        Map params = new HashMap();
        params.put("suite_id", suiteId);
        params.put("suite_secret", secret);
        params.put("suite_ticket", suiteTicketDao.getLatest(suiteId).getSuitTicket());
        params.put("code", code);

        return extClient.get("GetUserInfo3rd", params, UserInfo3rd.class);
    }

}
